#! /usr/bin/env python
# toyoutube

"""Convert video files to the format preferred by YouTube."""

import sys
from libtovid.opts import parse
from libtovid import cli

def convert(infile, outfile):
    cmd = cli.Command('ffmpeg')
    cmd.add('-i', infile,
            '-vcodec', 'libxvid',
            '-r', 30,
            '-s', '320x240',
            '-b', '500k',
            '-acodec', 'libmp3lame',
            '-ab', '64k',
            '-ar', 44100,
            '-y',
            outfile + '.avi')
    cmd.run()

if __name__ == '__main__':
    if len(sys.argv) < 5:
        print "Usage: toyoutube -in FILE -out {output prefix}"
        sys.exit(1)

    options = parse(sys.argv[1:])

    convert(options['in'], options['out'])
